/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gui;

import java.awt.Component;
import javax.swing.JProgressBar;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author Jonas
 */
public class TableProgressBar extends JProgressBar implements TableCellRenderer {

    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        if (value == null) {
            this.setValue(0);
        } else {
            this.setMinimum(0);
            this.setMaximum(100);
            this.setValue((Integer)value);
            if(this.getValue() > 0) {
                this.setStringPainted(true);
            } else {
                this.setStringPainted(false);
            }
        }
        return this;
    }

}
